<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>转账</title>
    <link href="res/style.css" rel="stylesheet">
    <script src="http://47.106.66.89:8080/js/vue.min.js"></script>
    <script src="http://47.106.66.89:8080/js/axios.min.js"></script>
    <link href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
    <script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
</head>
<body>
<div id="app" class="flex">
    <main>
        <header class="flex">
            <div>
                <h3>源辰银行</h3>
                <small>ycinfo bank</small>
            </div>
            <div id="contact">
                <div>客服电话: 8888</div>
                <div>网址: www.ycinfo.bank.com</div>
            </div>
        </header>
        <div class="msg">
            倒计时: <h2>32</h2> 秒
        </div>
        <div id="pane" class="flex">
            <div class="btns">
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
            </div>
            <div id="info">
                <h2>转账服务</h2>
                <form action="main.html">
                    <input placeholder="转入账号" type="number" v-model="id2"><br>
                    <input placeholder="转入金额" type="number" v-model="money">
                </form>
            </div>
            <div class="btns">
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a class="right" @click="transfer">确定</a>
                <a class="right" @click="main">返回</a>
            </div>
        </div>
    </main>
</div>
</body>
<script>
    var v = new Vue({
        el:"#app",
        data:{
            money : "",
            id2 : ""
        },
        methods:{
            getUrlKey: function (name) {
                return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
            },

            transfer(){
                let params = new URLSearchParams();
                var id1 = this.getUrlKey("id");
                params.append("id1", id1)
                params.append("id2", this.id2)
                params.append("money", this.money)
                axios.post("transfer", params).then(res=>{
                    if(res.data.code == 1){
                        this.$message(res.data.msg)
                        this.id2 = ""
                        this.money = ""
                    }else{
                        this.$message(res.data.msg)
                    }
                })
            },
            main(){
                var uid = this.getUrlKey("id");
                location.href = "main.html?id="+uid
            }
        }
    })
</script>
</html>
